package fuza.android.thetrafficsigns;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.Window;

public class SplashActivity extends Activity{
	
	private static final int SPLASH_TIME = 3*1000;
	DBHandler dbHelper;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_splash);
		
		dbHelper = new DBHandler(this);
        try {
			dbHelper.createDataBase();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			new Handler().postDelayed(new Runnable() {
				
				@Override
				public void run() {
					Intent splashIntent = new Intent(SplashActivity.this, MainActivity.class);
					startActivity(splashIntent);
					
					SplashActivity.this.finish();
					
					overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
					
				}
			}, SPLASH_TIME);
			
			new Handler().postDelayed(new Runnable() {
				
				@Override
				public void run() {
				}
			}, SPLASH_TIME);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	@Override
	public void onBackPressed() {
		this.finish();
		super.onBackPressed();
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.splash, menu);
		return true;
	}

}
